/**
 * Copyright (C), 2018-2020, 飞尔智能有限公司
 * FileName: OrderService
 * Author:   杨乐
 */
package com.yangle.eurekaclientproducter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @description:
 * @Author 杨乐
 * @Date 2020/1/26 16:26
 * @Version 1.0
 **/
@RestController
public class OrderConsumerService {
    @Autowired
    @Qualifier("restTemplate")
    private RestTemplate restTemplate;
    @Autowired
    @Qualifier("restTemplate2")
    private RestTemplate restTemplate2;

    @RequestMapping("getOrder")
    public String getOrder() {
        return restTemplate.getForObject("http://192.168.31.168:8081/getOrder", String.class);
    }

    //    实现负载均衡的服务，不需要指定节点，只需要指定使用的服务名称
    @RequestMapping("getOrderForLoadBalence")
    public String getOrderForLoadBalence() {
        return restTemplate2.getForObject("http://eureka-client-order-service/getOrder", String.class);
    }
}
    
